<?php

class friends_util_contactlist{
	public function getGuilds($uid){
		$search = new MultiFetcher();
		$url = "http://gh.178.com/gu.php?u=$uid&s=".md5($uid."178gh") ;
		$search->push('guild', $url);
		$result = $search->fetch();
		$ret = array();
		if(!$result['guild']['error'] and $result['guild']['content']){
			list($domain, $name) = explode("@", $result['guild']['content']);
			array_push($ret, array($domain, $name));
		}
		return $ret;
	}
	
	public function getGuildMembers($domain){
		$search = new MultiFetcher();
		$url = "http://gh.178.com/gm.php?d=$domain&s=".md5($domain."178gh");
		$search->push('members', $url);
		$result = $search->fetch();
		if(!$result['members']['error']){
			$members = unserialize($result['members']['content']);
			return $members;
		}
		return array();
	}
}